#!/bin/bash
## Platform:All Linux Based Platform
## author:Long Tao
## version:1.0
## description:This is quwan project start script
## Company:QuDan
echo '================开始启动项目==================='
# 镜像仓库
IMAGE_DEPOSITORY=ccr.ccs.tencentyun.com/qudan/qudan
# username
DEPOSITORY_USERNAME=100022109603
# password
DEPOSITORY_PASSWORD=qudan@2021
base_dir=$PWD
app_name=docker_test
# 端口
port=8098
echo "当前目录：" "$base_dir"

# 进度条
function pull_sleep() {
  for ((i=0;$i<=20;i++)) ;
  do
    let jinshu=$i*5
    printf "[%-20s]%d%%\r" $b $jinshu
    sleep 0.2
    b=#$b
  done
  echo "拉取镜像完成"
}

#echo '================正在拉取镜像==================='
docker login --username="$DEPOSITORY_USERNAME" --password="$DEPOSITORY_PASSWORD" "$IMAGE_DEPOSITORY"
docker pull "$IMAGE_DEPOSITORY":"$app_name"
# 切换到app用户启动
pull_sleep
#
## 启动镜像
#echo '================启动测试镜像==================='
docker run --name "$app_name" -d -p "$port":"$port" -v /home/app/jar/docker_test/docker_test.jar:/tmp/docker_test.jar "$IMAGE_DEPOSITORY":"$app_name"
